﻿#region Using directives

using System;
using System.ComponentModel;
using NetROS.Tiers.Entities.Validation;

#endregion

namespace NetROS.Tiers.Entities
{
    ///<summary>
    /// An object representation of the 'tblPutniNalogStavkaPrijevoz' table. [No description found the database]	
    ///</summary>
    /// <remarks>
    /// This file is generated once and will never be overwritten.
    /// </remarks>	
    [Serializable]
    [CLSCompliant(true)]
    public partial class PutniNalogStavkaPrijevoz : PutniNalogStavkaPrijevozBase
    {
        #region Constructors

        ///<summary>
        /// Creates a new <see cref="PutniNalogStavkaPrijevoz"/> instance.
        ///</summary>
        public PutniNalogStavkaPrijevoz() : base() { }

        #endregion
        protected override void AddValidationRules()
        {


            base.AddValidationRules();
            ValidationRules.AddRule(Validation.CommonRules.StringRequired, "RelacijaOd");
            ValidationRules.AddRule(Validation.CommonRules.StringRequired, "RelacijaDo");
            ValidationRules.AddRule(Validation.CommonRules.GreaterThanOrEqualToValue<Decimal?>,  new Validation.CommonRules.CompareValueRuleArgs<Decimal?> ("Kilometara", 0));
            ValidationRules.AddRule(Validation.CommonRules.GreaterThanOrEqualToValue<Decimal?>,  new Validation.CommonRules.CompareValueRuleArgs<Decimal?> ("PoKm", 0));
        }

        [DescriptionAttribute(""), System.ComponentModel.Bindable(System.ComponentModel.BindableSupport.Yes)]
        [DataObjectField(false, false, false)]
        public virtual System.Decimal IznosKalkuliran
        {
            get
            {
                return Math.Round((PoKm * Kilometara), 2, MidpointRounding.AwayFromZero);
            }
        }


           [DescriptionAttribute("Kalkuliranje brojilo od"), System.ComponentModel.Bindable(System.ComponentModel.BindableSupport.Yes)]
        [DataObjectField(false, false, true)]
        public virtual System.Decimal? BrojcanikOd
        {
            get { return BrojiloPocetak; }
               set
               {
                   BrojiloPocetak = value;
                   Kilometara = (BrojiloKraj ?? 0m) -(BrojiloPocetak ?? 0m) ;
               }
        }

           [DescriptionAttribute("Kalkuliranje brojilo do"), System.ComponentModel.Bindable(System.ComponentModel.BindableSupport.Yes)]
        [DataObjectField(false, false, true)]
        public virtual System.Decimal? BrojcanikDo
        {
            get { return BrojiloKraj; }
            set
            {
                BrojiloKraj = value;
                Kilometara = (BrojcanikDo ?? 0m) - (BrojcanikOd ?? 0m) ;
            }
        }
    }
}
